#include "stdafx.h"
#include "qtabcontrol.h"

using namespace micro::gui;


QTabControl::QTabControl(void)
{
	nrTabs = 0;
}

QTabControl::~QTabControl(void)
{
}


bool QTabControl::Create(QWindow* parent, int id, UINT style)
{

	  CreateBaseWindow(
		  WC_TABCONTROL,
      nullptr, style |
	  WS_VISIBLE | WS_BORDER | WS_CHILD | 
      WS_CLIPCHILDREN | WS_CLIPSIBLINGS 
	  |TCS_FLATBUTTONS |TCS_FOCUSNEVER
	  | TCS_TABS  
	  | TCS_SINGLELINE
	  | TCS_HOTTRACK 
	  
	 
      ,QRect(0,0,0,0), parent, id   );   //nu trebuie this, clasa inregistrata automat cu wndProc proprie
										//deci doar parintele primeste WM_NOTIFY

 
	
	   SetPadding(  20, 4);

	   SendMessage( WM_SETFONT, (WPARAM)GetStockObject( DEFAULT_GUI_FONT ), (LPARAM)TRUE );
 
			 
	 return _window!=nullptr;
	  
}

 

void  QTabControl::InsertTab(QString label)
{
	 
    
	
	TCITEM tc;
	memset(&tc, 0, sizeof(tc) ) ;
	 

	tc.mask = TCIF_IMAGE |TCIF_PARAM | TCIF_TEXT;
	tc.lParam = 0;
	tc.iImage = -1;
	tc.pszText = (LPWSTR)(LPCTSTR)label;

	tc.cchTextMax  = label.GetLength();;
 
	TabCtrl_InsertItem(_window, nrTabs++, &tc);


  

}

void  QTabControl::SetUnicodeFormat(BOOL bo)
{ 
	TabCtrl_SetUnicodeFormat(_window, bo);
  
}
 
void  QTabControl::AdjustRect(BOOL flag, QRect &rect)
{ 
	TabCtrl_AdjustRect(_window, flag, &rect);
  
}
 
int  QTabControl::GetCurSel()
{ 
	return TabCtrl_GetCurSel(_window);
  
}

void QTabControl::SetOwnerDraw(void)
{
	this->ModifyStyle(0,TCS_OWNERDRAWFIXED);
}

